package com.px.chapter_Dec_1.thread;

public class Test3 {
    public static void main(String[] args) {
       sys yyy=new sys();
       Thread thread1 = new Thread(yyy, "1号");
        Thread thread2 = new Thread(yyy, "2号");



           thread1.start();
           thread2.start();

    }
}
 class  sys  implements Runnable{

    private int yy=30;
    @Override
    public  void run() {

        for (int o=1;yy>0;o++){
            synchronized (this){
                if (yy<=0)break;
                yy--;
            }
            System.out.println(Thread.currentThread().getName()+"正在出售第"+o);

        }}

}
